package org.example.zixuansuo;

import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.AtomicStampedReference;

public class myLock {
        AtomicReference<Thread> atomicReference =new AtomicReference<>();

        public  void  myLock(){
            Thread thread = Thread.currentThread();
            System.out.println(thread.getName()+"==> myLock");
            while(!atomicReference.compareAndSet(null,thread)){

            }
        }

    public  void  myUnLock(){
        Thread thread = Thread.currentThread();
        System.out.println(thread.getName()+"==> myUnLock");
        atomicReference.compareAndSet(thread,null);
    }

}
